import requests
import json
import time
import datetime
import random

def Rtime():
    t = time.time()
    RanTime = (int(round(t * 1000000)))
    return RanTime


def workOrder():
    headers = {
      'Content-Type': 'application/json'
    }
    url = "https://dohko-api-hllopen.tiaofangzi.com/hllopen/workorder/v1/workorder/createWorkOrder.svc?token=134b1a64d8ad4cb7bdf49f0d27c3714d&grant_type=refresh_token&app_key=MIS_TIAOFANGZI"
    body = {
      "customerType": "O",
      "customerContact": "zhangteng",
      "customerMobile": "1233123",
      "customerEmail": "123123@163.com",
      "businessType": "WORK_ORDER_BUSINESS_TYPE_5",
      "workOrderSource": "Online",
      "subject": "zkkSubject" + str(Rtime()),
      "body": "zkk工单内容" + str(Rtime()),
      "priorityLevel": "Workorder_priority_low",
      "isOrderEnd": "02",
      "workOrderTempID": "20220111101750242635",
      "dataJson": "{\"hardwareReportInfo\":{\"reportDate\":\"20211210\",\"backDate\":\"\",\"mobile\":\"18331586638\",\"description\":\"触摸卡顿\",\"reporter\":\"程永超\",\"doneDate\":\"\",\"problemType\":\"触摸问题\",\"reportDays\":\"\"},\"hardwareRepairInfo\":{\"reportTypeTime\":\"20211210\",\"expressWay\":\"快递\",\"reportDetails\":\"需要返厂维修\",\"factoryPrice\":\"100\",\"appraiseResult\":\"\",\"chargeType\":\"收费\",\"costPrice\":\"50\",\"repairType\":\"返厂维修\",\"createType\":\"内部下单\",\"remark\":\"测试创建升级报修接口\",\"chargeStatus\":\"未收款\",\"customerOffer\":\"100\",\"returnTime\":\"20211210\",\"reportType\":\"收到设备,未收到设备,检修中\",\"expressNumber\":\"234324234\",\"expressCompany\":\"顺丰快递\",\"newSNCode\":\"\",\"customerCharge\":\"300\",\"invoiceStatus\":\"待开票\"},\"hardwareBasicInfo\":{\"empID\":\"85636\",\"outDate\":\"20201102\",\"customerUseDays\":\"\",\"hardwareType\":\"服务器\",\"customerName\":\"\",\"orgID\":\"1625\",\"sales\":\"测试18266668888\",\"subsidiary\":\"北京大客\",\"customerType\":\"\",\"enterDate\":\"20201102\",\"hardwareName\":\"G鸡肉可以出库\",\"hardwareCode\":\"0103020011\",\"supplier\":\"我也不知道\",\"customerID\":\"\",\"outDays\":\"\",\"hardwareSNCode\":\"sn\",\"customer\":\"食欲762\"}}",
      "version": "2.0",
      "createEmpID": 100001378,
      "orderAttaches":""
    }


    response = requests.post(url, headers=headers, data=json.dumps(body))
    print(response.json())


for i in range(10):
    workOrder()
    print("第" + str(i + 1) + "次")
